using System;
using Holoville.HOTween;
using UnityEngine;

[RequireComponent(typeof(tk2dUIItem))]
public class ClickColorUpDown : MonoBehaviour
{
	private void OnEnable()
	{
		tk2dUIItem component = base.GetComponent<tk2dUIItem>();
		if (component != null)
		{
			component.OnDownUIItem += this.OnDown;
			component.OnUpUIItem += this.OnUp;
		}
	}

	private void OnDisable()
	{
		tk2dUIItem component = base.GetComponent<tk2dUIItem>();
		if (component != null)
		{
			component.OnDownUIItem -= this.OnDown;
			component.OnUpUIItem -= this.OnUp;
		}
	}

	private void OnDown(tk2dUIItem item)
	{
		this.SetColor(true);
	}

	private void OnUp(tk2dUIItem item)
	{
		this.SetColor(false);
	}

	private void SetColor(bool isDown)
	{
		HOTween.Kill(this.tk2dSprite);
		HOTween.To(this.tk2dSprite, 0.2f, "color", (!isDown) ? this.upColor : this.downColor);
	}

	public tk2dBaseSprite tk2dSprite;

	public Color upColor = Color.white;

	public Color downColor = Color.white;
}
